<template>
  <div class="page-template">
    <div class="page-header">
      <h1>{{ title }}</h1>
      <p v-if="description">{{ description }}</p>
    </div>

    <div class="page-content">
      <el-card>
        <template #header>
          <div class="card-header">
            <span>{{ title }}</span>
            <el-button 
              v-if="showAddButton" 
              type="primary" 
              :icon="Plus" 
              @click="$emit('add')"
            >
              添加
            </el-button>
          </div>
        </template>

        <div class="content-area">
          <slot name="content">
            <div class="placeholder-content">
              <el-empty description="功能开发中">
                <template #image>
                  <el-icon size="64"><Tools /></el-icon>
                </template>
                <el-button type="primary" disabled>敬请期待</el-button>
              </el-empty>
            </div>
          </slot>
        </div>
      </el-card>
    </div>
  </div>
</template>

<script setup lang="ts">
import { Plus, Tools } from '@element-plus/icons-vue'

interface Props {
  title: string
  description?: string
  showAddButton?: boolean
}

defineProps<Props>()

defineEmits<{
  add: []
}>()
</script>

<style scoped>
.page-template {
  padding: 20px;
}

.page-header {
  margin-bottom: 20px;
}

.page-header h1 {
  margin: 0 0 8px 0;
  color: #303133;
  font-size: 24px;
}

.page-header p {
  margin: 0;
  color: #606266;
  font-size: 14px;
}

.card-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
}

.content-area {
  min-height: 400px;
}

.placeholder-content {
  display: flex;
  justify-content: center;
  align-items: center;
  height: 400px;
}
</style>
